﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace XData.Services.Client
{
    public class ApiClient
    {
        HttpClient HttpClient = new HttpClient();

        public async Task<XElement> PutAsync(XElement xe)
        {
            HttpClient.DefaultRequestHeaders.Accept.Clear();
            HttpClient.DefaultRequestHeaders.Add("Accept", "application/xml");
            
        
            HttpContent content = new StringContent(xe.ToString(),Encoding.UTF8, "application/xml");

            var v = await HttpClient.PutAsync("http://localhost:13308/Data/Xml", content);
            string s = await v.Content.ReadAsStringAsync();
            XElement result = XElement.Parse(s);
            return result;
        }
    }
}
